﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace System.Windows.Controls {
	public static class ControlEx {
		private static bool? isInDesignModeStatic;
		public static bool IsDesignMode(this Control me) {
			if (isInDesignModeStatic.HasValue) {
				// only do the check once and use the last value forever
				return isInDesignModeStatic.Value;
			}
			try {
				var isoStor = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Contains("asasdasd");
				isInDesignModeStatic = false;
				return isInDesignModeStatic.Value;
			} catch (Exception ex) {
				// Toss out any errors we get
			}
			// If we get here that means we got an error
			isInDesignModeStatic = true;
			return isInDesignModeStatic.Value;
		}
	}
}
